package com.study.spark.scala.chapter07

import scala.collection.mutable


object Scala07_Collection_Set{
  def main(args: Array[String]): Unit = {
    // TODO 集合 - Set
    // 数据无序，不可重复
    val set =Set(1,2,3,3,2,1,6,5,4)
    println(set)//Set(5, 1, 6, 2, 3, 4)

    // 可变Set集合：mutable.Set
    val mutableSet = mutable.Set(2,3,4,1,5)
    mutableSet.add(666)
    println(mutableSet)//Set(1, 5, 2, 666, 3, 4)
    mutableSet.update(666,false)
    println(mutableSet)//Set(1, 5, 2, 3, 4)
    mutableSet.update(666,true)
    println(mutableSet)//Set(1, 5, 2, 666, 3, 4)
    mutableSet.remove(1)
    println(mutableSet)//Set(5, 2, 666, 3, 4)
  }
}
